package cn.cmft.jc.transform.parse;

import java.util.List;
import java.util.Map;

public class ChangeOptionMessage {

    private String host;
    private int port;
    private String database;
    private String table;
    private Long tmMs;
    private String ddl;
    private Map<ChangeOperationType,List<ChangeDetail>> changeOperations;

    public static class Builder{
        ChangeOptionMessage changeOptionMessage;

        public Builder(){
            this.changeOptionMessage = new ChangeOptionMessage();
        }


        public Builder host(String host){
            this.changeOptionMessage.host = host;
            return this;
        }

        public Builder port(int port){
            this.changeOptionMessage.port = port;
            return this;
        }


        public Builder database(String db){
            this.changeOptionMessage.database = db;
            return this;
        }

        public Builder table(String table){
            this.changeOptionMessage.table = table;
            return this;
        }
        public Builder tmMs(Long tmMs){
            this.changeOptionMessage.tmMs = tmMs;
            return this;
        }
        public Builder ddl(String ddl){
            this.changeOptionMessage.ddl = ddl;
            return this;
        }

        public Builder changeOperations(Map<ChangeOperationType, List<ChangeDetail>> changeOperations){
            this.changeOptionMessage.changeOperations =changeOperations;
            return this;
        }

        public ChangeOptionMessage build(){
            return this.changeOptionMessage;
        }
    }

    public String getHost() {
        return host;
    }

    public int getPort() {
        return port;
    }

    public String getDatabase() {
        return database;
    }

    public String getTable() {
        return table;
    }

    public Long getTmMs() {
        return tmMs;
    }

    public String getDdl() {
        return ddl;
    }

    public Map<ChangeOperationType, List<ChangeDetail>> getChangeOperations() {
        return changeOperations;
    }

    @Override
    public String toString() {
        return "{" +
                "host='" + host + '\'' +
                ", port=" + port +
                ", database='" + database + '\'' +
                ", table='" + table + '\'' +
                ", tmMs=" + tmMs +
                ", ddl='" + ddl.replace("\\r\\n"," ") + '\'' +
                ", changeOperations=" + changeOperations +
                '}';
    }
}
